<?php
namespace PsiFramework\Applications\AlloMediaPortal\Classes\Model;

import("Classes.Model.Object");

use \PsiFramework\Classes\Model\Object;

/**
 * AlloMedia
 * Portail des professionnels
 *
 * @author Rémi San
 * @version beta
 */

/**
 * Classe de liaison d'une catégorie avec un site web allomedia
 *
 * @package Model
 */
class CategoryLink extends Object
{

    protected /*AlloMediaSite*/ $_site ;
    protected /*SiteCategory*/  $_category ;
    protected /*int*/           $_idForSite ;

    public function __construct(
        /*AlloMediaSite*/ $site=null,
        /*SiteCategory*/ $category=null,
        /*int*/ $idForSite=null
    )
    {
        $this->_site = $site ;
        $this->_category = $category ;
        $this->_idForSite = $idForSite ;
    }

    public function getId()
    {
        if (is_null($this->_site) && is_null($this->_category)) {
        	return null ;
        } else {
            $id = array();
            if (!is_null($this->_site)) {
            	$id["site"] = $this->_site ;
            }
            if (!is_null($this->_category)) {
            	$id["category"] = $this->_category ;
            }
            return $id ;
        }
    }

    public function getSite()
    {
        return $this->_site ;
    }

    public function setSite($site)
    {
        $this->_site = $site;
    }

    public function getCategory()
    {
        return $this->_category ;
    }

    public function setCategory($category)
    {
        $this->_category = $category;
    }

    public function getIdForSite()
    {
        return $this->_idForSite ;
    }

    public function setIdForSite($idForSite)
    {
        $this->_idForSite = $idForSite;
    }

    public function toString()
    {
        $string = "" ;
        if (!is_null($this->_site)) {
            $string .= $this->_site->getName() . " - "  ;
        }
        if (!is_null($this->_category)) {
            $string .= $this->_category->toString() . " - " ;
        }
        $string .= $this->_idForSite ;

        return $string ;
    }
}
